<?php
// Copyright 2019 Hackware SpA <human@hackware.cl>
// This file is part of "Hackware Web Services Wallet" and licensed under
// the terms of the GNU Affero General Public License version 3, or (at your
// option) a later version. You should have received a copy of this license
// along with the software. If not, see <https://www.gnu.org/licenses/>.

namespace Hawese\Wallet\Http\Controllers;

use Hawese\Wallet\Currency;
use Hawese\Core\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Http\Response;

class CurrencyController extends Controller
{
    public function __construct()
    {
        //
    }

    public function show($idOrCode)
    {
        if (is_numeric($idOrCode)) {
            $currency = Currency::find($idOrCode);
        } else {
            $currency = Currency::findByCode($idOrCode);
        }

        return $this->singleResponse($currency);
    }

    public function index(Request $request)
    {
        return $this->collectionResponse($request, Currency::class);
    }
}
